package cn.com.thinvent.dispatch.web.controller;

import cn.com.thinvent.dispatch.entity.DataCleanAlgorithm;
import cn.com.thinvent.dispatch.entity.DataCleanResult;
import cn.com.thinvent.dispatch.entity.ModelFiletag;
import cn.com.thinvent.dispatch.entity.response.PagedGridResult;
import cn.com.thinvent.dispatch.entity.response.ReturnModel;
import cn.com.thinvent.dispatch.service.biz.DataCleanAlgorithmService;
import cn.com.thinvent.dispatch.service.biz.ModelFiletagService;
import io.swagger.annotations.Api;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 算法配置模块
 */
@Api(description = "算法配置模块")
@Controller
@RequestMapping("/dataCleanAlgorithm")
@CrossOrigin(origins = "*")
@ResponseBody
public class DataCleanAlgorithmController {

    @Autowired
    private DataCleanAlgorithmService dataCleanAlgorithmService;

    /**
     * 执行目标列表
     * @param dataCleanAlgorithm
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/list")
    @ResponseBody
    public ReturnModel list(DataCleanAlgorithm dataCleanAlgorithm,
                            @RequestParam("pageNum") Integer pageNum,
                            @RequestParam("pageSize") Integer pageSize) {
        PagedGridResult<DataCleanAlgorithm> list = dataCleanAlgorithmService.list(dataCleanAlgorithm, pageNum, pageSize);
        return new ReturnModel(200, list, "");
    }

    /**
     * 新增或修改目标对象
     * @param dataCleanAlgorithm
     * @return
     */
    @PostMapping("/saveOrUpdate")
    @ResponseBody
    public ReturnModel saveOrUpdate(@RequestBody DataCleanAlgorithm dataCleanAlgorithm) {
        DataCleanAlgorithm target = dataCleanAlgorithmService.saveOrUpdate(dataCleanAlgorithm);
        return new ReturnModel(200, target, "");
    }

    /**
     * 删除执行目标条件
     * @param dataCleanAlgorithm
     * @return
     */
    @PostMapping("/delete")
    @ResponseBody
    public ReturnModel delete(@RequestBody DataCleanAlgorithm dataCleanAlgorithm) {
        Integer delete = dataCleanAlgorithmService.delete(dataCleanAlgorithm.getId());
        return new ReturnModel(200, delete, "");
    }
    /**
     * 详情
     * @param id 主键id
     * @return
     */
    @GetMapping("/detail")
    @ResponseBody
    public ReturnModel detail(@Param("id") Integer id) {

        DataCleanAlgorithm result = dataCleanAlgorithmService.getById(id);

        return new ReturnModel(200, result, "");
    }
}
